﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CodeCube.Business.Implements;
using CodeCube.Common;
using CodeCube.Core.DtoModel;
using CodeCube.Core.DtoModel.KTDataTable;
using CodeCube.Service.Interfaces;
using CodeCube.Service.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace CodeCube.Api.Controllers
{
    /// <summary>
    /// 车库通讯接口
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Produces("application/json")]
    [ApiExplorerSettings(GroupName = "CodeCube")]
    public class GarageController : ControllerBase
    {
        //private readonly IGarageService _GarageService;
        //private readonly ICartypeService _CartypeService;
        //private readonly IKeyclassService _KeyclassService;
        //private readonly IKeywordService _KeywordService;
        //private readonly INavlineService _NavlineService;
        //private readonly ITrainnumberService _TrainnumberService;
        ///// <summary>
        ///// 初始注入
        ///// </summary>
        ///// <param name="mGarageService">车库操作工具</param>
        ///// <param name="mCartypeService">车型操作工具</param>
        ///// <param name="mKeyclassService">关键词分类操作工具</param>
        ///// <param name="mKeywordService">关键词操作工具</param> 
        ///// <param name="mNavlineService">段落导航操作工具</param>
        ///// <param name="mTrainnumberService">班次操作工具</param>
        //public GarageController(
        //    IGarageService mGarageService,
        //    ICartypeService mCartypeService,
        //    IKeyclassService mKeyclassService,
        //    IKeywordService mKeywordService,
        //    INavlineService mNavlineService,
        //    ITrainnumberService mTrainnumberService)
        //{
        //    _GarageService = mGarageService;
        //    _CartypeService = mCartypeService;
        //    _KeyclassService = mKeyclassService;
        //    _KeywordService = mKeywordService;
        //    _NavlineService = mNavlineService;
        //    _TrainnumberService = mTrainnumberService;
        //}
        //#region 数据查询
        ///// <summary>
        ///// 获取车辆班次数据表
        ///// </summary>
        ///// <param name="parm"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<KTDataTable<TrainnumberModel>> GetTrainnumberKTDataTable([FromBody]KTDataTableDto parm)
        //{
        //    return await _TrainnumberService.GetKTDataTableAsync(parm);
        //}
        ///// <summary>
        ///// 获取车辆列表
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<KTDataTable<GarageModel>> GetCarList([FromBody]KTDataTableDto parm)
        //{
        //    return await _GarageService.GetKTDataTableAsync(parm);
        //}
        ///// <summary>
        ///// 获取车辆信息
        ///// </summary>
        ///// <param name="parm"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<KTDataTable<CartypeModel>> GetCartypeList([FromBody]KTDataTableDto parm)
        //{
        //    return await _CartypeService.GetKTDataTableAsync(parm);
        //}
        ///// <summary>
        ///// 查询车牌号
        ///// </summary>
        ///// <param name="str"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<List<string>>> GetCarPlateList([FromBody]StringParm str)
        //{
        //    var list = await _GarageService.GetListAsync(m => m.CarPlate.Contains(str.str), n => n.CarPlate, DbOrderEnum.Asc);
        //    var res = new List<string>();
        //    foreach(var m in list.data)
        //    {
        //        res.Add(m.CarPlate);
        //    }
        //    return await Task.Run(() => new ApiResult<List<string>> { data = res });
        //}
        ///// <summary>
        ///// 获取导航线路
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<List<NavlineModel>>> GetNavline([FromBody]StringParm str)
        //{
        //    return await _NavlineService.GetListAsync(m => m.CarPlate == str.str, n => n.Index, DbOrderEnum.Asc);
        //}
        ///// <summary>
        ///// 获取关键分类词列表
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<List<KeyclassModel>>> GetKeyclass()
        //{
        //    return await _KeyclassService.GetListAsync();
        //}
        ///// <summary>
        ///// 获取关键词列表
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<List<KeywordModel>>> GetKeyword([FromBody]IntParm id)
        //{
        //    if (id.num==null)
        //    {
        //        return await _KeywordService.GetListAsync();
        //    }
        //    else
        //    {
        //        return await _KeywordService.GetListAsync(m => m.ClassID == id.num, n => n.ID, DbOrderEnum.Asc);
        //    }
        //}
        //#endregion
        //#region 数据编辑
        ///// <summary>
        ///// 添加车辆
        ///// </summary>
        ///// <param name="parm">车辆信息</param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> AddCar([FromBody]GarageModel parm)
        //{
        //    return await _GarageService.AddAsync(parm);
        //}
        ///// <summary>
        ///// 编辑车辆
        ///// </summary>
        ///// <param name="parm"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> EdtCar([FromBody]GarageModel parm)
        //{
        //    return await _GarageService.UpdateAsync(parm);
        //}
        ///// <summary>
        ///// 删除车辆
        ///// </summary>
        ///// <param name="carplate"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> DelCar([FromBody]string carplate)
        //{

        //    return await _GarageService.DeleteAsync(m => m.CarPlate == carplate);
        //}
        ///// <summary>
        ///// 添加导航线路
        ///// </summary>
        ///// <param name="parm"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> AddNavline([FromBody]NavlineModel parm)
        //{
        //    return await _NavlineService.AddAsync(parm);
        //}
        ///// <summary>
        ///// 修改导航线路
        ///// </summary>
        ///// <param name="parm"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> EdtNavline([FromBody]NavlineModel parm)
        //{
        //    return await _NavlineService.UpdateAsync(parm);
        //}
        ///// <summary>
        ///// 删除导航线路
        ///// </summary>
        ///// <param name="guid"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> DelNavline([FromBody]string guid)
        //{
        //    return await _NavlineService.DeleteAsync(m => m.GUID == guid);
        //}
        ///// <summary>
        ///// 添加车型
        ///// </summary>
        ///// <param name="parm"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> AddCartype([FromBody]CartypeModel parm)
        //{
        //    return await _CartypeService.AddAsync(parm);
        //}
        ///// <summary>
        ///// 编辑车型
        ///// </summary>
        ///// <param name="parm"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> EdtCartype([FromBody]CartypeModel parm)
        //{
        //    return await _CartypeService.UpdateAsync(parm);
        //}
        ///// <summary>
        ///// 删除车型
        ///// </summary>
        ///// <param name="parm"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> DelCartype([FromBody]StringParm parm)
        //{
        //    return await _CartypeService.DeleteAsync(m => m.GUID == parm.str);
        //}
        ///// <summary>
        ///// 添加关键词分类
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> AddKeyclass([FromBody]KeyclassModel parm)
        //{
        //    return await _KeyclassService.AddAsync(parm);
        //}
        ///// <summary>
        ///// 修改关键词分类
        ///// </summary>
        ///// <param name="parm"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> EdtKeyclass([FromBody]KeyclassModel parm)
        //{
        //    return await _KeyclassService.UpdateAsync(parm);
        //}
        ///// <summary>
        ///// 删除关键词分类
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> DelKeyclass(int id)
        //{
        //    return await _KeyclassService.DeleteAsync(m=>m.ID==id);
        //}
        ///// <summary>
        ///// 添加关键词
        ///// </summary>
        ///// <param name="parm"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> AddKeyword([FromBody]KeywordModel parm)
        //{
        //    return await _KeywordService.AddAsync(parm);
        //}
        ///// <summary>
        ///// 编辑关键词
        ///// </summary>
        ///// <param name="parm"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> EdtKeyword([FromBody]KeywordModel parm)
        //{
        //    return await _KeywordService.UpdateAsync(parm);
        //}
        ///// <summary>
        ///// 删除关键词
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<ApiResult<string>> DelKeyword(int id)
        //{
        //    return await _KeywordService.DeleteAsync(m => m.ID == id);
        //}
        //#endregion
    }
}